<?php

if(isset($_POST['submit'])){
    $kode = $_POST['kode'];
    $nama = $_POST['nama'];
    
    $query = mysql_query("insert into ms_rek3(kd_rek3, nm_rek3) values ('$kode','$nama')");
    if($query){
        echo 'berhasil simpan';
    }else{
        echo 'gagal';
    }
}
    
?>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>   
   
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>easyui/themes/default/easyui.css"/>
    <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>easyui/themes/icon.css"/>
    <link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>easyui/demo/demo.css"/>
    <script type="text/javascript" src="<?php echo base_url(); ?>easyui/jquery-1.8.0.min.js"></script>
    <script type="text/javascript" src="<?php echo base_url(); ?>easyui/jquery.easyui.min.js"></script>
    <script type="text/javascript" src="<?php echo base_url(); ?>easyui/jquery.edatagrid.js"></script>

    <link href="<?php echo base_url(); ?>easyui/jquery-ui.css" rel="stylesheet" type="text/css"/>
    <script src="<?php echo base_url(); ?>easyui/jquery-ui.min.js"></script>

    <script type="text/javascript">
        var kode;
        var nama;
        $(document).ready(function(){
            $('#dg').edatagrid({
                url         : '<?php echo site_url()?>/utilitas/mrek3',
                idField     : 'id',
                rownumbers  : "true",
                fitColumns  : "true",
                singleSelect: "true",
                showFooter  : true,
                nowrap      : false,
                columns:[[
                    {field  : 'kd_rek3',
                     title  : 'Kode Rekening',
                     width  : 100},
                    {field  : 'nm_rek3',
                     title  : 'Nama Rekening Rekening',
                     width  : 500}
                ]],
                onSelect:function(rowIndex,rowData){
                    kode   = rowData.kode;
                    nama   = rowData.nama;
                } 
            });
        });
        
        function hapus(){
            $(document).ready(function(){
                    var row = $('#dg').datagrid('getSelected');
                    if (row){
                            alert(nama);
                    } 
            });
            
        }
        
        function cetak(){
            var filter = document.getElementById('filter').value;
            window.open('<?php echo site_url()?>/utilitas/cetak_mrek3/'+filter, 'Cetak Laporan');
        }
        
    </script>
</head>
    
<body>
    <table id="dg" title="LATIHAN" style="width:1025%;height:300%" ></table>
    Filter : <input type="text" id="filter">
    <input type="button" value="Cetak" id="cetak" onclick="cetak()"/>
    <form method="POST" action="">
        Kode : <input type="text" id="kode" name="kode">
        Nama : <input type="text" id="nama" name="nama">
            <input type="submit" id="submit" name="submit" value="simpan">
            <input type="button" id="hapus" name="hapus" value="hapus" onclick="hapus()">
    </form>
</body>
    
</html>